home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / COMMUNIC / MRUN211.ZIP / MRUN211E.WAS < prev    next >
Text File  |  1993-05-01  |  20KB  |  745 lines

  1. ;MailRun v2.11:  Part E, addulfile
  2. ;1992-1993 Gerald P. Sully, all rights reserved.
  3.  
  4. #comment
  5. **************************************************************************
  6. **************************************************************************
  7. * This file contains routines related to adding a "Upload File"
  8. * item to a mailrun.  It puts up the Upload Files dialog box,
  9. * which displays the contents of the available files index (the
  10. * *.udx file for the mailrun).  When a file is selected from the 
  11. * list, a detailed description is displayed from the *.ubf file 
  12. * for the mailrun).
  13. **************************************************************************
  14. **************************************************************************
  15. #endcomment
  16.  
  17. #define MRUN211E
  18. #define MRUN211DE
  19.  
  20. #include "mrun211.h"
  21.  
  22. string DXFileTabs, OldUDX, OldUBF, MRunUDX, MRunUBF, LastChoice
  23. string UploadDir, DownloadDir, BBSChoice
  24. integer InULDir, ULSortField
  25.  
  26. #comment
  27. *********************************************************************
  28. * MAIN()
  29. * Calls checkchild(), updateudx(), interfaceon(), getnewdesc(),
  30. * getulfiles(), checkchanged(), getlastitem(), gettaskstring(), 
  31. * clearfiledesc(), makebbslist(), ulfilebox(), insertulfile(), 
  32. * delulfile(), menudim(), makefullname(), sortidx(), checkfile()
  33. * Adds a SendFile item to the mailrun.  An feditbox is
  34. * used to display the file description in order to take
  35. * advantage of wordwrap.  The flistbox displays the
  36. * contents of MAILRUN.UDX, which contains information on
  37. * any file downloaded by MailRun, plus additional files
  38. * found in the upload directory.  A file description must
  39. * be at least 6 characters, but may be as long as needed.
  40. *********************************************************************
  41. #endcomment
  42.  
  43. proc main
  44. string FullFileName, char, temp
  45. integer dialogstatus
  46. integer j, InUDX
  47.     menudim()
  48.     checkchild()
  49.     findfirst MailRun
  50.     MailRunTrunc = $FILENAME
  51.     DXFileTabs = "58,92,130,305,315,319,322,325,328"
  52.     profilerd MailRun "MailRun" "UploadDir" UploadDir
  53.     profilerd MailRun "MailRun" "DownloadDir" DownloadDir
  54.     profilerd MailRun "MailRun" "ULSortField" ULSortField
  55.     strextract BBSChoice TaskItem "`t" 3
  56.     strextract char TaskItem "`t" 4
  57.     atoi char j
  58.     FileDesc = makefullname(TempDir, "DESC.TMP")
  59.     OldUDX = makefullname(TempDir, "OLDUDX.TMP")
  60.     OldUBF = makefullname(TempDir, "OLDUBF.TMP")
  61.     MRunUDX = makefullname(MailRunDir, "MAILRUN.UDX")
  62.     MRunUBF = makefullname(MailRunDir, "MAILRUN.UBF")
  63.     if isfile FileDesc
  64.         delfile FileDesc
  65.     endif
  66.     if not (checkfile(MRunUDX) && checkfile(MRUNUBF))
  67.         getulfiles()
  68.     endif
  69.     LastChoice = ""
  70.     FLAGS &= UNCHANGED
  71.     interfaceon()
  72.     makebbslist()
  73.     ulfilebox()
  74.     dialogstatus = $DIALOG
  75.     while dialogstatus != 1
  76.         switch dialogstatus
  77.             case 10
  78.                 ;User selected "Add"
  79.                 insertulfile(&j)
  80.                 TaskItem = gettaskstring(BBSChoice, j)
  81.             endcase
  82.             case 11
  83.                 ;User selected "Save"
  84.                 if FLAGS & CHANGED
  85.                     updateudx()
  86.                     FLAGS &= UNCHANGED
  87.                     updatedlg -1
  88.                 endif
  89.             endcase
  90.             case 12
  91.                 ;User selected "Delete"
  92.                 delulfile()
  93.             endcase
  94.             case 13
  95.                 ;User selected "Refresh"
  96.                 statmsg "Refreshing Uploads List from Upload Directory..."
  97.                 getulfiles()
  98.                 updatedlg -1
  99.                 statmsg ""
  100.             endcase
  101.             case 50
  102.                 ;User selected a sort radiobutton
  103.                 profilewr MailRun "MailRun" "ULSortField" ULSortField
  104.                 sortidx(MRunUDX, ULSortField)
  105.                 updatedlg 16
  106.             endcase
  107.             case 130
  108.                 ;User selected a file from the listbox
  109.                 if checkchanged()
  110.                     getnewdesc()
  111.                     updatedlg 137
  112.                 else
  113.                     FileChoice = LastChoice
  114.                     updatedlg 16
  115.                 endif
  116.             endcase
  117.             case 170
  118.                 ;User changed BBSs with the combobox
  119.                 j = getlastitem(BBSChoice)
  120.                 TaskItem = gettaskstring(BBSChoice, j)
  121.             endcase
  122.             case 230
  123.                 ;User entered a name in the File Name box
  124.                 FullFileName = makefullname(UploadDir, FileName)
  125.                 if isfile FullFileName
  126.                     InULDir = 1
  127.                 else
  128.                     InULDir = 0
  129.                 endif
  130.                 interfaceoff()
  131.                 openfile(MRunUDXFile, MRunUDX, _READWRITE, _TEXT)
  132.                 InUDX = checkudx(FileName)
  133.                 if InUDX
  134.                     fseek MRunUDXFile -100 1
  135.                     fgets MRunUDXFile FileChoice
  136.                     fgets MRunUDXFile FileChoice
  137.                     strextract temp FileChoice "`t" 0
  138.                     while not strcmpi temp FileName
  139.                         fgets MRunUDXFile FileChoice
  140.                         strextract temp FileChoice "`t" 0
  141.                     endwhile
  142.                 endif
  143.                 fclose MRunUDXFile
  144.                 interfaceon()
  145.                 if InUDX
  146.                     makedesc(MRunUBF)
  147.                 else                
  148.                     clearfiledesc()
  149.                 endif
  150.                 updatedlg -1
  151.             endcase
  152.             case 250
  153.                 ;User entered a file description
  154.                 if !(FLAGS & CHANGED)
  155.                     FLAGS |= CHANGED
  156.                 endif
  157.             endcase
  158.         endswitch
  159.         dialogstatus = $DIALOG
  160.     endwhile
  161. endproc
  162.  
  163.  
  164. #comment
  165. *********************************************************************
  166. * INSERTULFILE()
  167. * Called by main()
  168. * Calls openfile(), updateudx(), insertitem(),
  169. * interfaceon(), interfaceoff(), makefullname(), checkudx(),
  170. * clearfiledesc(), shortdesc()
  171. * Adds a SendFile item to the *.MRN file and the task list.
  172. *********************************************************************
  173. #endcomment
  174.  
  175. proc insertulfile
  176. intparm j
  177. string ULDescString, ULFileString, FullFileName
  178. string ULFileSpec, StatString, CopyboxMsg
  179. integer ULDescLength, Perm, Response, InUDX
  180.     interfaceoff()
  181.     if NULLSTR FileName
  182.         ;User hasn't selected a file
  183.         usermsg "You must select a file first."
  184.         return
  185.     endif
  186.     if InULDir == 0
  187.         strupr FileName
  188.         strfmt CopyBoxMsg \
  189.             "%s is not in the Upload Directory.`r`nCopy it now?" \
  190.             FileName
  191.         strlwr FileName
  192.         sdlgmsgbox "MailRun Message" CopyBoxMsg QUESTION \
  193.             OKCANCEL Response 1
  194.         switch Response
  195.             case 1
  196.                 ;User selected "OK"
  197.                 ULFileSpec = makefullname(DownloadDir, FileName)
  198.                 dir ULFileSpec FullFileName
  199.                 if NULLSTR FullFileName
  200.                     return
  201.                 endif
  202.                 if not isfile FullFileName
  203.                     sdlgmsgbox "MailRun Message" "No such file!" \
  204.                         EXCLAMATION OK Response 1
  205.                     return
  206.                 endif
  207.                 copyfile FullFileName UploadDir
  208.                 if not strcmpi ULFileSpec FullFileName
  209.                     ;if the user chose a file other than the one specified
  210.                     ;get the name of the file
  211.                     findfirst FullFileName
  212.                     FileName = $FILENAME
  213.                     strlwr FileName
  214.                     ;determine whether it is already in the uploads database
  215.                     openfile(MRunUDXFile, MRunUDX, _READWRITE, _TEXT)
  216.                     InUDX = checkudx(FileName)
  217.                     fclose MRunUDXFile
  218.                     if InUDX == 0
  219.                         ;if it isn't in the uploads database, put it there
  220.                         clearfiledesc()
  221.                         FLAGS |= CHANGED
  222.                         updateudx()
  223.                     endif
  224.                 endif
  225.                 InULDir = 1
  226.                 updatedlg -1
  227.             endcase
  228.             case 2
  229.                 ;User selected "Cancel"
  230.                 return
  231.             endcase
  232.         endswitch
  233.     endif
  234.     ;No description may be less than 6 characters
  235.     openfile(FileDescFile, FileDesc, _READWRITE, _NORMAL)
  236.     fread FileDescFile ULDescString 65 ULDescLength
  237.     fclose FileDescFile
  238.     if ULDescLength < 6
  239.         usermsg "Please enter a longer description."
  240.     elseif shortdesc(ULDescString, ULDescLength)
  241.         ;If everything is OK...
  242.         if FLAGS & CHANGED
  243.             ;Add the new description to the database
  244.             updateudx()
  245.             FLAGS &= UNCHANGED
  246.             updatedlg 16
  247.         endif
  248.         Perm = 2 - PermRadio
  249.         strupr FileName
  250.         strfmt ULFileString \
  251.             "1,%d,SendFile,%s,%s" Perm FileName Conf
  252.         strfmt StatString \
  253.             "Added to %s:  `"Upload %s to Conference %s`"" \
  254.             BBSChoice FileName Conf
  255.         j++
  256.         insertitem(BBSChoice, j, ULFileString)
  257.         strlwr FileName
  258.         statmsg StatString
  259.     endif
  260.     interfaceon()
  261. endproc
  262.  
  263.  
  264. #comment
  265. *********************************************************************
  266. * SHORTDESC()
  267. * Called by insertulfile()
  268. * Calls findstring()
  269. * If the current BBS type is WildCat! or RBBS, limits the 
  270. * upload description length to 60 or 45 characters,
  271. * respectively.  Gives user an opportunity to enter a new 
  272. * description if the current one is too long.
  273. *********************************************************************
  274. #endcomment
  275.  
  276. func shortdesc : integer
  277. strparm ULDescString
  278. intparm ULDescLength
  279. string ULMsg, TypeName
  280. integer Response, MaxL